﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace ChinaSoft.Web.Model_tb_MidSoft_ProjectInfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int ProjectInfoId=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(ProjectInfoId);
				}
			}
		}
			
	private void ShowInfo(int ProjectInfoId)
	{
		ChinaSoft.BLL.BLL_tb_MidSoft_ProjectInfo bll=new ChinaSoft.BLL.BLL_tb_MidSoft_ProjectInfo();
		ChinaSoft.Model.Model_tb_MidSoft_ProjectInfo model=bll.GetModel(ProjectInfoId);
		this.lblProjectInfoId.Text=model.ProjectInfoId.ToString();
		this.txtProjectName.Text=model.ProjectName;
		this.txtProjectSpecialty.Text=model.ProjectSpecialty;
		this.txtMarker.Text=model.Marker;
		this.txtArea.Text=model.Area;
		this.txtCustomer.Text=model.Customer;
		this.txtProperty.Text=model.Property;
		this.txtDescription.Text=model.Description;
		this.txtCreateTime.Text=model.CreateTime.ToString();
		this.txtCreateUserId.Text=model.CreateUserId.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtProjectName.Text.Trim().Length==0)
			{
				strErr+="项目名称不能为空！\\n";	
			}
			if(this.txtProjectSpecialty.Text.Trim().Length==0)
			{
				strErr+="专业不能为空！\\n";	
			}
			if(this.txtMarker.Text.Trim().Length==0)
			{
				strErr+="标识不能为空！\\n";	
			}
			if(this.txtArea.Text.Trim().Length==0)
			{
				strErr+="区域不能为空！\\n";	
			}
			if(this.txtCustomer.Text.Trim().Length==0)
			{
				strErr+="业主单位不能为空！\\n";	
			}
			if(this.txtProperty.Text.Trim().Length==0)
			{
				strErr+="性质不能为空！\\n";	
			}
			if(this.txtDescription.Text.Trim().Length==0)
			{
				strErr+="项目概况不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtCreateTime.Text))
			{
				strErr+="创建时间格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtCreateUserId.Text))
			{
				strErr+="创建人ID格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int ProjectInfoId=int.Parse(this.lblProjectInfoId.Text);
			string ProjectName=this.txtProjectName.Text;
			string ProjectSpecialty=this.txtProjectSpecialty.Text;
			string Marker=this.txtMarker.Text;
			string Area=this.txtArea.Text;
			string Customer=this.txtCustomer.Text;
			string Property=this.txtProperty.Text;
			string Description=this.txtDescription.Text;
			DateTime CreateTime=DateTime.Parse(this.txtCreateTime.Text);
			int CreateUserId=int.Parse(this.txtCreateUserId.Text);


			ChinaSoft.Model.Model_tb_MidSoft_ProjectInfo model=new ChinaSoft.Model.Model_tb_MidSoft_ProjectInfo();
			model.ProjectInfoId=ProjectInfoId;
			model.ProjectName=ProjectName;
			model.ProjectSpecialty=ProjectSpecialty;
			model.Marker=Marker;
			model.Area=Area;
			model.Customer=Customer;
			model.Property=Property;
			model.Description=Description;
			model.CreateTime=CreateTime;
			model.CreateUserId=CreateUserId;

			ChinaSoft.BLL.BLL_tb_MidSoft_ProjectInfo bll=new ChinaSoft.BLL.BLL_tb_MidSoft_ProjectInfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
